package com.railway.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.railway.service.SuggestionsService;
import com.railway.service.impl.SuggestionsServiceImpl;
@WebServlet("/DelSuggtion.do")
public class DelSuggestionServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("application/json");
		req.setCharacterEncoding("UTF-8");
		String suggestionId = req.getParameter("suggestionId");
		int id = Integer.parseInt(suggestionId);
		SuggestionsService sg = new SuggestionsServiceImpl();
		int msg = sg.delSuggtion(id);
		if(msg == 1) {
			resp.getWriter().print("success");
		}
	}
	
}
